﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using System.Data;

namespace logic
{
    public class buyerRange
    {
        public static void buyerRangeInsert(int companyId, int productId, string remarks, double amount, string businessnature)
        {
            BuyerRange.buyerRangeInsert(companyId, productId, remarks, amount, businessnature);
        }

        public static void buyerRangeSelectedItemsInsert(string productIds, int companyId)
        {
            BuyerRange.buyerRangeSelectedItemsInsert(productIds, companyId);
        }

        public static void buyerRangeInsertByRootCategory(int companyId, int rootCategory, string businessNature)
        {
            BuyerRange.buyerRangeInsertByRootCategory(companyId, rootCategory, businessNature);
        }

        public static void buyerRangeInsertBySubCategory(int companyId, int subCategory, string businessNature)
        {
            BuyerRange.buyerRangeInsertBySubCategory(companyId, subCategory, businessNature);
        }

        /// <summary>
        /// 批量添加采购范围
        /// </summary>
        /// <param name="companyId">采购商</param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static bool BuyerRangeBulkCopy(int companyId, DataTable dt)
        {
            return BuyerRange.BuyerRangeBulkCopy(companyId, dt);
        }

        public static DataTable listWithCompanyRange(int companyId)
        {
            return BuyerRange.listWithCompanyRange(companyId);
        }

        public static DataTable listWithCategoryAndCompany(int companyId, int categoryId)
        {
            return BuyerRange.listWithCategoryAndCompany(companyId, categoryId);
        }

        /// <summary>
        /// 查询企业采购范围中的大类列表
        /// </summary>
        /// <param name="companyId"></param>
        /// <returns></returns>
        public static DataTable rootCategorylistWithCompanyRange(int companyId)
        {
            return BuyerRange.rootCategorylistWithCompanyRange(companyId);
        }
        /// <summary>
        /// 查询企业采购范围中的小类列表
        /// </summary>
        /// <param name="companyId"></param>
        /// <param name="parentCategoryId"></param>
        /// <returns></returns>
        public static DataTable subCategory_listWithCompanyRange(int companyId, int parentCategoryId)
        {
            return BuyerRange.subCategory_listWithCompanyRange(companyId, parentCategoryId);
        }

        public static DataSet list(string where, string orderby, int pagesize, int pageindex)
        {
            return DAL.DbHelper.ExecuteDataSetPageSize("*", "vw_BuyerRange_list", where, "brid", orderby, pagesize, pageindex);
        }
        public static DataTable rootCategorylistWithCompanyId(int companyId)
        {
            return BuyerRange.rootCategorylistWithCompanyId(companyId);
        }
        public static DataTable subCategorylistWithCompanyIdAndParentCategoryId(int companyId, int parentCategoryId)
        {
            return BuyerRange.subCategorylistWithCompanyIdAndParentCategoryId(companyId, parentCategoryId);
        }
        public static DataSet listWithPrice(string where, string orderby, int pagesize, int pageindex)
        {
            return DAL.DbHelper.ExecuteDataSetPageSize("productNo,name,unit,productId,newPrice,isCurrentCost,remarks,businessNature,NatureCode", "vw_BuyerRange_listWithPrice_PhoneOrder", where, "brid", orderby, pagesize, pageindex);
        }

        public static void delete(int companyId, int productId, string businessnature)
        {
            BuyerRange.delete(companyId, productId, businessnature);
        }

        public static void deleteBySelected(string productIds, int companyId)
        {
            BuyerRange.deleteBySelected(productIds, companyId);
        }

        public static void deleteByRootCategory(int rootCategory, int companyId)
        {
            BuyerRange.deleteByRootCategory(rootCategory, companyId);
        }

        public static void deleteBySubCategory(int subCategory, int companyId)
        {
            BuyerRange.deleteBySubCategory(subCategory, companyId);
        }

        /// <summary>
        /// 查询企业未采购的商品
        /// </summary>
        /// <param name="companyId">企业编号</param>
        /// <param name="where">查询筛选条件</param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public static DataSet listWithCompanySubtraction(int companyId, string where, int pageSize, int pageIndex)
        {
            return BuyerRange.listWithCompanySubtraction(companyId, where, pageSize, pageIndex);
        }

        public static DataTable rootCategory_buyerRange_Subtraction(int companyId)
        {
            return BuyerRange.rootCategory_buyerRange_Subtraction(companyId);
        }
        public static DataTable subCategory_buyerRange_Subtraction(int companyId, int parentCategoryId)
        {
            return BuyerRange.subCategory_buyerRange_Subtraction(companyId, parentCategoryId);
        }

        public static void buyerRangeInsertBySecondLevel(int companyId, int categoryId, int flag)
        {
            BuyerRange.buyerRangeInsertBySecondLevel(companyId, categoryId, flag);
        }

        public static void insertByProductId(string company, int productid)
        {
            BuyerRange.insertByProduct(company, productid);
        }

        public static void buyerRangeUpdateByRemark(int companyId, int productId, string remarks, double amount, string businessnature)
        {
            BuyerRange.buyerRangeUpdateByRemark(companyId, productId, remarks, amount, businessnature);
        }

        /// <summary>
        /// 查询企业采购范围中的大类列表--常规商品（根据供应范围外的）
        /// </summary>
        /// <param name="companyId"></param>
        /// <returns></returns>
        public static DataTable rootCategorylistWithCompanyNotRange(int companyId)
        {
            return BuyerRange.rootCategorylistWithCompanyNotRange(companyId);
        }
        /// <summary>
        /// 查询企业采购范围中的小类列表--常规商品（根据供应范围外）
        /// </summary>
        /// <param name="companyId"></param>
        /// <param name="parentCategoryId"></param>
        /// <returns></returns>
        public static DataTable subCategory_listWithCompanyNotRange(int companyId, int parentCategoryId)
        {
            return BuyerRange.subCategory_listWithCompanyNotRange(companyId, parentCategoryId);
        }

        /// <summary>
        /// 根据类别查询企业的采购范围--常用规商品
        /// </summary>
        /// <param name="companyId"></param>
        /// <param name="categoryId"></param>
        /// <returns></returns>
        public static DataTable listWithCategoryAndCompanyNotRange(int companyId, int categoryId)
        {
            return BuyerRange.listWithCategoryAndCompanyNotRange(companyId, categoryId);
        }

        /// <summary>
        /// 查询大类列表--特价商品
        /// </summary>
        /// <param name="companyId"></param>
        /// <returns></returns>
        public static DataTable ProductSpecials_RootCategory_listCategory(int companyId)
        {
            return BuyerRange.ProductSpecials_RootCategory_listCategory(companyId);
        }

        /// <summary>
        /// 小类-特价商品
        /// </summary>
        /// <param name="parentCategoryId"></param>
        /// <returns></returns>
        public static DataTable ProductSpecials_SubCategory_listCategory(int companyId, int parentCategoryId)
        {
            return BuyerRange.ProductSpecials_SubCategory_listCategory(companyId, parentCategoryId);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="companyId"></param>
        /// <param name="categoryId"></param>
        /// <returns></returns>
        public static DataTable ProductSpecials_listWithCategoryIdAndCompanyId(int companyId, int categoryId)
        {
            return BuyerRange.ProductSpecials_listWithCategoryIdAndCompanyId(companyId, categoryId);
        }

        /// <summary>
        /// 企业信息编辑时如果修改【采购商级别】，则提示是否将采购商采购范围中所有商品从原来的级别迁移到新的级别来
        /// </summary>
        /// <param name="companyId">采购商ID</param>
        /// <param name="newnature">修改后的采购商级别（工厂、酒店、政府机关）</param>
        /// <param name="oldnature">原有的采购商级别</param>
        public static void buyerRangeBycompanyIdBusinessNature(int companyId, string newnature, string oldnature)
        {
            BuyerRange.buyerRangeBycompanyIdBusinessNature(companyId,newnature,oldnature);
        }
    }
}
